import csv
import plotly.express as px
import pandas as pd

filename = 'data/world_fires_1_day.csv'

with open(filename) as f:
    reader = csv.reader(f)
    header_row = next(reader)

# 提取经度,维度,火灾强度
    lons,lats,brights=[],[],[]
    for row in reader:
        lon = float(row[1])
        lat = float(row[0])
        bright = float(row[2])

        lons.append(lon)
        lats.append(lat)
        brights.append(bright)

print(lons[:6])
print(lats[:6])
print(brights[:6])

#数据可视化
data=pd.DataFrame(zip(lons,lats,brights),columns=['经度','维度','火灾强度'])
fig =px.scatter(
    data,
    x='经度',
    y='维度',
    range_x=[-200,200],
    range_y=[-90,90],
    title="全球火灾散点图",
    size='火灾强度',
    size_max=10,
    color='火灾强度'
)

fig.write_html('global_world_fires.html')
fig.show()